package edu.guigu.networkconnection.network;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @Description: (用一句话描述)
 * @author yuanc
 * @date 2025/8/25 16:37
 */
public class GithubClient {
    private GithubApi githubApi;
    public GithubClient() {

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

        OkHttpClient okhttpclient = new OkHttpClient.Builder()
                .addInterceptor(interceptor)  // 添加日志拦截器
                .build();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://api.github.com")
                .client(okhttpclient)
                // 添加GOSN转换器
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        // TODO
        githubApi = retrofit.create(GithubApi.class);
    }

    public GithubApi getGithubApi() {
        return githubApi;
    }
}
